﻿<Window x:Class="FlagTunes.View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:FlagTunes.View"
        xmlns:converters="clr-namespace:FlagTunes.View"
        Title="FlagTunes" Height="700" Width="1000"
        Closing="Window_Closing" KeyUp="Window_KeyUp"
        WindowState="Maximized" Icon="/FlagTunes;component/Icons/PlayIcon.png">
    <Window.DataContext>
        <local:MainWindowViewModel x:Name="mainWindowViewModel" />
    </Window.DataContext>
    <Window.Resources>
        <converters:TimeSpanConverter x:Key="TimeSpanConverter" />
    </Window.Resources>
    <Grid Grid.Row="0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Menu Height="25" Width="Auto">
            <MenuItem Header="Program">
                <MenuItem Name="addMusicMenuItem" Header="Add Music" Click="addMusicMenuItem_Click" />
            </MenuItem>
        </Menu>
        <Grid Grid.Row="1" Height="30">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" Margin="0, 0, 5, 0" Command="{Binding Path=PlayCommand}" ToolTip="Play song" BorderThickness="0" BorderBrush="Transparent" Background="Transparent" >
                <Image Source="Icons\PlayIcon.png" />
            </Button>
            <Button Grid.Column="1" Margin="0, 0, 5, 0" Command="{Binding Path=PauseCommand}" ToolTip="Pause song" BorderThickness="0" BorderBrush="Transparent" Background="Transparent" >
                <Image Source="Icons\PauseIcon.png" />
            </Button>
            <Button Grid.Column="2" Margin="0, 0, 5, 0" Name="stopButton" Click="stopButton_Click" ToolTip="Stop song" BorderThickness="0" BorderBrush="Transparent" Background="Transparent" >
                <Image Source="Icons\StopIcon.png" />
            </Button>
            <Slider Grid.Column="3" VerticalAlignment="Center" Margin="0, 0, 5, 0" Width="200" Maximum="1" LargeChange="0.1" Interval="10" Delay="50" Value="{Binding Path=PlayerVolume}" ToolTip="Volume" IsMoveToPointEnabled="True" />
            <Slider Grid.Column="4" VerticalAlignment="Center" Margin="0, 0, 5, 0" Width="Auto" Value="{Binding Path=LoadedSongElapsedSeconds, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Interval="1" Delay="0" Maximum="{Binding Path=LoadedSongTotalTime.TotalSeconds, UpdateSourceTrigger=PropertyChanged}" ToolTip="Time slider" IsMoveToPointEnabled="True" />
            <TextBlock Grid.Column="5" Width="Auto" MinWidth="50" TextAlignment="Right" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{Binding Path=LoadedSongElapsedTime, Converter={StaticResource TimeSpanConverter}}" ToolTip="Current song time" />
            <TextBlock Grid.Column="6" Width="Auto" VerticalAlignment="Center" Text="/" />
            <TextBlock Grid.Column="7" Margin="0, 0, 5, 0" Width="Auto" MinWidth="50" TextAlignment="Left" VerticalAlignment="Center" HorizontalAlignment="Right" Text="{Binding Path=LoadedSongTotalTime, Converter={StaticResource TimeSpanConverter}}" ToolTip="Total song time" />
            <TextBox Grid.Column="8" Width="150" HorizontalAlignment="Right" Text="{Binding Path=SearchPattern, UpdateSourceTrigger=PropertyChanged}" MaxLines="1" ToolTip="Search field" Name="searchTextBox" GotFocus="searchTextBox_GotFocus" />
        </Grid>
        <Grid Grid.Row="2">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="175" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid Grid.Column="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Border Grid.Row="0" BorderBrush="{x:Null}" Height="22">
                        <TextBlock TextWrapping="Wrap" Text="Artists" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Border>
                    <ListBox Grid.Row="1" ItemsSource="{Binding Path=Artists, UpdateSourceTrigger=PropertyChanged, IsAsync=True}" SelectedItem="{Binding Path=SelectedArtist, UpdateSourceTrigger=PropertyChanged}" />
                    <Button Grid.Row="2" Content="All Artists" Command="{Binding Path=ResetArtistFilterCommand}" Height="25" ToolTip="Show all artists" />
                </Grid>
                <Grid Grid.Column="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="200" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <ListView Grid.Row="0" ItemsSource="{Binding Path=CurrentSongs, UpdateSourceTrigger=PropertyChanged, IsAsync=True}" SelectedItem="{Binding Path=SelectedSong}" SelectionMode="Single">
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="Title" DisplayMemberBinding="{Binding Path=Title}" />
                                <GridViewColumn Header="Artist" DisplayMemberBinding="{Binding Path=Artist}" />
                                <GridViewColumn Header="Album" DisplayMemberBinding="{Binding Path=Album}" />
                                <GridViewColumn Header="Genre" DisplayMemberBinding="{Binding Path=Genre}" />
                            </GridView>
                        </ListView.View>
                        <ListView.ItemContainerStyle>
                            <Style TargetType="ListViewItem">
                                <EventSetter Event="MouseDoubleClick" Handler="song_MouseDoubleClick" />
                            </Style>
                        </ListView.ItemContainerStyle>
                    </ListView>
                    <ListView Grid.Row="1">
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="Title" DisplayMemberBinding="{Binding Path=Title}" />
                                <GridViewColumn Header="Artist" DisplayMemberBinding="{Binding Path=Artist}" />
                                <GridViewColumn Header="Album" DisplayMemberBinding="{Binding Path=Album}" />
                                <GridViewColumn Header="Genre" DisplayMemberBinding="{Binding Path=Genre}" />
                            </GridView>
                        </ListView.View>
                    </ListView>
                </Grid>
            </Grid>
        </Grid>
        <StatusBar Grid.Row="3" Name="statusBar" Height="25" Width="Auto">
            <StatusBarItem HorizontalAlignment="Left" >
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Total songs: " />
                    <TextBlock Text="{Binding Path=LibrarySongCount}" />
                    <TextBlock Text=" / " />
                    <TextBlock Text="Displayed songs: " />
                    <TextBlock Text="{Binding Path=DisplayedSongs.Count}" />
                </StackPanel>
            </StatusBarItem>
            <StatusBarItem HorizontalAlignment="Right" >
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Current song: " FontWeight="Bold" />
                    <TextBlock Text="{Binding Path=LoadedSong.Title, UpdateSourceTrigger=PropertyChanged}" />
                    <TextBlock Text=" - " />
                    <TextBlock Text="{Binding Path=LoadedSong.Album, UpdateSourceTrigger=PropertyChanged}" />
                    <TextBlock Text=" - " />
                    <TextBlock Text="{Binding Path=LoadedSong.Artist, UpdateSourceTrigger=PropertyChanged}" />
                </StackPanel>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>